package logic

import (
	"DataSrv/global/model"
	"context"

	"DataSrv/data"
	"DataSrv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoUpdateLogic {
	return &VideoUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoUpdateLogic) VideoUpdate(in *data.VideoUpdateRequest) (*data.VideoUpdateResponse, error) {
	// todo: add your logic here and delete this line
	var Video model.Video
	if err := model.DB.Where("id = ?", in.Id).Find(&Video).Error; err != nil {
		return nil, err
	}
	Video.Status = int(in.Ok)
	Video.StatusDes = in.Des
	if err := model.DB.Updates(&Video).Error; err != nil {
		return nil, err
	}
	return &data.VideoUpdateResponse{}, nil
}
